#include <bits/stdc++.h>
using namespace std;
const int oo=1e5+5;
int n;
int num[oo];
int knum[oo];
int main(){
    freopen("duel.in",'r',stdin);
    freopen("duel.out",'w',stdout);
    cin>>n;
    int maxn=-oo,minn=oo;
    for(int i=1;i<=n;i++){
        cin>>num[i];
        minn=min(num[i],minn);
        maxn=max(num[i],maxn);
        knum[num[i]]++;
    }
    int maxnum=0,minnum=0;
    for(int i=1;i<=n;i++){
        if (minn=num[i]) minnum++;
        else if (maxn=num[i]) maxnum++;
    }
    int ia=n-maxnum-minnum;
    cout<<minnum-maxnum+1;
    fclose(stdin);
    flcose(stdout);
    return 0;
}


